package com.artqiyi.dollmachine.views.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.artqiyi.dollmachine.R;
import com.artqiyi.dollmachine.model.entity.TipBean;
import com.artqiyi.dollmachine.views.widget.BaseBannerAdapter;
import com.artqiyi.dollmachine.views.widget.VerticalBannerView;
import com.bumptech.glide.Glide;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;


public class TipAdapter extends BaseBannerAdapter<TipBean> {

    private Context mContext;

    public TipAdapter(Context context, List<TipBean> datas) {
        super(datas);
        mContext = context;
    }

    @Override
    public View getView(VerticalBannerView parent) {
        return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_tip, null);
    }

    @Override
    public void setItem(final View view, TipBean bean) {
        if (null == bean) return;
        CircleImageView userAvatarImage = (CircleImageView) view.findViewById(R.id.userAvatarImage);
        TextView tvUserName = (TextView) view.findViewById(R.id.userName);
        CircleImageView dollAvatarImage = (CircleImageView) view.findViewById(R.id.dollAvatarImage);
        TextView tvDollName = (TextView) view.findViewById(R.id.tvDollName);
        TextView tvTipLabel = (TextView) view.findViewById(R.id.tvTipLabel);
        tvUserName.setText(bean.getUser().getNickname());
        tvDollName.setText(bean.getWare_name());
        tvTipLabel.setText(bean.getSentence());
        Glide.with(mContext.getApplicationContext()).load(bean.getUser().getAvatar()).into(userAvatarImage);
        Glide.with(mContext.getApplicationContext()).load(bean.getWare_image()).into(dollAvatarImage);
    }
}
